package ljl.alg.jianzhioffer.round3.easy;

import java.util.Arrays;

public class _61_isStraight {

    class wode {
        public boolean isStraight(int[] nums) {
            Arrays.sort(nums);
            int zeros = 0;
            int i = 0;
            int len = nums.length;
            while (nums[i++] == 0)
                zeros++;
            for (int j = i; j < len; j++) {
                if (nums[j - 1] == nums[j])
                    return false;
            }
            return nums[len - 1] - nums[zeros] < 5;
        }
    }

    /**
     * 非常鸡贼 因为总共五张牌
     * */
    class lufei {
        public boolean isStraight(int[] nums) {
            Arrays.sort(nums);
            int joker = 0;
            for (int i = 0; i < 4; i++) {
                if (nums[i] == 0)
                    joker++;
                else if (nums[i] == nums[i + 1])
                    return false;
            }
            return nums[4] - nums[joker] < 5;
        }
    }
}
